package com.zzyl.nursing.controller.member;

import com.aliyun.iot20180120.models.QueryDevicePropertyStatusRequest;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.DeviceDataPage;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.BindFamilyDto;
import com.zzyl.nursing.dto.DeviceDataDto;
import com.zzyl.nursing.dto.QueryDeviceDataListByDayDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.DeviceDataVo;
import com.zzyl.nursing.vo.FamilyListVo;
import com.zzyl.nursing.vo.FamilyMemberElderDetailVo;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }


    //家属绑定老人信息
    @PostMapping("/add")
    @ApiOperation("家属绑定老人信息")
    public AjaxResult save(@RequestBody BindFamilyDto dto){
        return toAjax(familyMemberService.save(dto));
    }


    //查询家人列表
    @GetMapping("my")
    @ApiOperation("查询家人列表")
    public R<List<FamilyListVo>> QueryMyFamilyList(){
        List<FamilyListVo>  vo=   familyMemberService.QueryMyFamilyList();
        return R.ok(vo);
    }

    // 查看已绑定家人列表（分页查询）
    @GetMapping("list-by-page")
    @ApiOperation("查询家人列表")
    public R<List<FamilyMemberElderDetailVo>> QueryFamilyListByPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                          @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
    {
        List<FamilyMemberElderDetailVo> voList=familyMemberService.QueryFamilyListByPage(pageNum,pageSize);
        return R.ok(voList);
    }

     //查询健康数据
    @PostMapping("QueryDevicePropertyStatus")
    @ApiOperation("查询健康数据")
    public R queryDevicePropertyStatus(@RequestBody QueryDevicePropertyStatusRequest request){
        return R.ok(familyMemberService.queryDevicePropertyStatus(request));
    }


    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public R<List<DeviceDataVo>> queryDeviceDataListByDay(DeviceDataDto dto){
        List<DeviceDataVo> list = familyMemberService.queryDeviceDataListByDay(dto);
        return R.ok(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public R<List<DeviceDataVo>> queryDeviceDataListByWeek(DeviceDataDto dto){
        List<DeviceDataVo> list = familyMemberService.queryDeviceDataListByWeek(dto);
        return R.ok(list);
    }



}
